<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function init(){
		document.querySelector("#btn_ajax1").addEventListener("click",()=>{
			let xhr=new XMLHttpRequest();
			xhr.open('get','doAjax1',true);
			xhr.onreadystatechange=function(){
				if(xhr.readyState==4&&xhr.status==200){
					let json=JSON.parse(xhr.responseText);
					alert(json.message);
				}
			};
			xhr.send(null);
		},false);
		document.querySelector("#btn_ajax2").addEventListener("click",()=>{
			let xhr=new XMLHttpRequest();
			xhr.open('get','doAjax2',true);
			xhr.onreadystatechange=function(){
				if(xhr.readyState==4&&xhr.status==200){
					let json=JSON.parse(xhr.responseText);
					alert(json.message);
				}
			};
			xhr.send(null);
		},false);
	}
	window.addEventListener("load",init,false);
</script>
</head>
<body>
<button id="btn_ajax1" type="button">ajax提交1</button>
<button id="btn_ajax2" type="button">ajax提交2</button>
</body>
</html>